package com.liveinstars.common.ticker;

/**
 * 基础交易对模型
 * Created by guoyanjiang on 2019-03-28.
 */
public class BasePair {
    private String symbol;//币种简称
    private String currencyUnit;//计价方式

    public BasePair(String pair) {
        String[] info = null;
        if (pair.contains("_")) {
            info = pair.split("_");
        } else if (pair.contains("/")) {
            info = pair.split("/");
        } else {
            throw new RuntimeException("交易对格式有误");
        }
        symbol = info[0];
        currencyUnit = info[1];
    }

    public BasePair(String symbol, String currencyUnit) {
        this.symbol = symbol;
        this.currencyUnit = currencyUnit;
    }

    public String getSymbol() {
        return symbol;
    }

    public String getCurrencyUnit() {
        return currencyUnit;
    }

    public String providePairStr(){
        return String.format("%s_%s", symbol, currencyUnit);
    }
}
